class Solution(object):
    def removeElement(self, nums:list[int], val):
        # while val in nums:
        #     nums.remove(val)
        nums[:] = [x for x in nums if x != val]
        return len(nums)


if __name__ == '__main__':
    s = Solution()
    nums = [0,1,2,2,3,0,4,2]
    val = 2
    s.removeElement(nums, val)
    print(nums)